<?php
    $dateNow = date('Y') - 5;
    $dateNext = date('Y') + 5;
?>
<script type="text/javascript">
$(document).ready(function(){
    getDatePicker('start_date');
    getDatePicker('end_date');
});

var baseUrl = '<?php echo $this->baseUrl(); ?>';
function getDatePicker(_id) {
    $("#"+_id).datepicker({
     showOn:'button',
     dateFormat:"dd-mm-yy",
     buttonImage:baseUrl+'/public/templates/admin/js/calendar/images/calendar.gif',
     buttonImageOnly:true,
     yearRange: '<?php echo $dateNow; ?>:<?php echo $dateNext; ?>',
     changeMonth:true,
     changeYear:true,
     showMonthAfterYear: true
   });
}
</script>
    <div class="list_category">
        <ul>
            <li><a href="<?php echo $this->baseUrl('admincp/evaluation'); ?>">Quản lý đánh giá</a></li>
        </ul>
    </div>
</div>

<!-- Begin Content -->
<div class="section">
    <div class="heading_section">
        <span>Quản lý đánh giá</span>
    </div>
    
    <div class="content">
    <p style="font-weight: bold; margin-left: 10px;">Tìm kiếm đánh giá:</p>
        <form action="" method="get">
            <table class="search-form">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('fullname','Họ và tên:'); ?></td>
                    <td class="td2"><?php echo $this->formText('fullname',$this->keyword['fullname'],array('class'=>'input')); ?></td>
                    <td class="td1"><?php echo $this->formLabel('status','Trạng thái:'); ?></td>
                    <td class="td2"><?php echo $this->formSelect('status',$this->keyword['status'],
                        array(
                            'class'=>'selectbox',
                        ),
                        array(
                            '0'=>'----------------- Tất cả ------------------',
                            '1'=>'Hiển thị',
                            '2'=>'Ẩn đi',
                        )); ?></td>
                    <td class="search-button" rowspan="2">
                        <?php echo $this->formSubmit('submit','Tìm kiếm',array('class'=>'button')); ?>
                    </td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('start_date','Ngày đăng từ:'); ?></td>
                    <td class="td2"><?php echo $this->formText('start_date',$this->keyword['start_date'],array('class'=>'input','style'=>'width:182px')); ?></td>
                    <td class="td1"><?php echo $this->formLabel('end_date','Đến ngày:'); ?></td>
                    <td class="td2"><?php echo $this->formText('end_date',$this->keyword['end_date'],array('class'=>'input','style'=>'width:182px')); ?></td>
                </tr>
            </table>
        </form>
        
        <form action="<?php echo $this->baseUrl('admincp/evaluation'); ?>" method="post">
        <p style="float: right; margin-right: 15px">Tổng số: <?php echo $this->total; ?> kết quả</p><br/>
        <table class="list-records">
            <tr class="list-header">
                <td>Họ và tên</td>
                <td>Nội dung</td>
                <td style="width: 120px;">Ngày cập nhật</td>
                <td width="70">Trạng thái</td>
                <td colspan="2">Tùy chọn</td>
                <td width="25"><?php echo $this->formCheckbox('check_all', null, array('id' => 'check_all', 'onClick' => 'checkAll()')); ?></td>
            </tr>
            <?php if(count($this->data) > 0) :
                $common = new Admincp_Model_Common();
                foreach($this->data as $value) : ?>
            <tr>
                <td><?php echo $value['fullname']; ?></td>
                <td><?php echo $common->cut_string($value['description'], 200, 1); ?></td>
                <td style="text-align: center;"><?php echo $common->formatDate($value['create_date']); ?></td>
                <td style="text-align: center;">
                    <a href="<?php echo $this->baseUrl('admincp/evaluation/publish?id=').$value['id'].'&status='.$value['status']; ?>">
                    <?php if($value['status'] == '1') : ?>
                        <img src="<?php echo $this->baseUrl(''); ?>public/templates/admin/images/publish.png" />
                    <?php else : ?>
                        <img src="<?php echo $this->baseUrl(''); ?>public/templates/admin/images/unpublish.png" />
                    <?php endif; ?>
                    </a>
                </td>
                <td class="tools">
                    <a href="<?php echo $this->baseUrl('admincp/evaluation/edit?id=').$value['id']; ?>">
                        <img src="<?php echo $this->baseUrl(''); ?>public/templates/admin/images/edit.png" />
                    </a>
                </td>
                <td class="tools">
                    <a href="<?php echo $this->baseUrl('admincp/evaluation/delete?id=').$value['id']; ?>" onclick="return remove_alert()">
                        <img src="<?php echo $this->baseUrl(''); ?>public/templates/admin/images/remove.png" />
                    </a>
                </td>
                <td class="tools"><?php echo $this->formCheckbox('check[]', $value['id']); ?></td>
            </tr>
            <?php endforeach; ?>
            <?php else : ?>
            <tr>
                <td colspan="7" style="font-style: italic;">Không tìm thấy kết quả nào</td>
            </tr>
            <?php endif; ?>
        </table>
        
        <div class="list-bottom">
            <?php if(count($this->data) > 0) : ?>
            <div class="pagination">
                <?php
        	        $currentUrl = '/?fullname='.$this->keyword['fullname'].'&status='.$this->keyword['status'].'&submit=Tìm+kiếm&start_date='.$this->keyword['start_date'].'&end_date='.$this->keyword['end_date'];
        	        echo $this->paginationControl($this->data, 'Sliding', 'evaluation/pagination_search.phtml', array('currentUrl' => $currentUrl));
                ?>
            </div>
            <?php endif; ?>
            
            <div class="list-buttons">
                <?php echo $this->formSubmit('refresh','Làm mới',array('class'=>'button')); ?>
                <?php echo $this->formSubmit('delete','Xóa',array('class'=>'button','onClick'=>'return remove_alert()')); ?>
            </div>
        </div>
        </form>
    </div>
</div>
<!-- End Content -->